package algorithm.middle;

import java.util.Arrays;

/**
 * @BelongsProject: LeetCode
 * @BelongsPackage: algorithm.middle
 * @Author: 江岸
 * @CreateTime: 2021-06-10 19:22
 * @Description:
 */
public class CoinChange {
    public static int coinChange(int[] coins, int amount) {
        Arrays.sort(coins);
        int count = 0;
        for (int i=coins.length-1;i>-1;i--){
            System.out.println("sss");
            while (amount>=coins[i]){
                amount-=coins[i];
                count++;
            }
        }
        if (amount>0) return -1;
        return count;
    }

    public static void main(String[] args) {
        coinChange(new int[]{186,419,83,408},6249);
    }
}
